package j2src;

import java.util.Vector;
import beans.CodeDetailDaoHome;
import beans.CodeDetailDaoReamote;
import beans.CodeDetailDto;


public class CodeDetailDaoDelegate {
	private CodeDetailDaoHome codeDetailDaoHome;
    private CodeDetailDaoReamote codeDetailDaoReamote;
    public CodeDetailDaoDelegate() throws Exception {
        initializeCodeDetailDaoHome();
        codeDetailDaoReamote = codeDetailDaoHome.create();
    }
    public Vector getAllCodeDetail(String codeId) throws Exception{
    	return codeDetailDaoReamote.getAllCodeDetail(codeId);
    }

	public CodeDetailDto getOneCodeDetail(String codeId, String detailCodeId) throws Exception{
		return codeDetailDaoReamote.getOneCodeDetail(codeId, detailCodeId);
	}
	
	public boolean insertCodeDetail(CodeDetailDto cdDto) throws Exception{
		return codeDetailDaoReamote.insertCodeDetail(cdDto);
	}
	
	public boolean updateCodeDetail(CodeDetailDto cdDto) throws Exception{
		return codeDetailDaoReamote.updateCodeDetail(cdDto);
	}
	
	
	public boolean deleteCodeDetail(CodeDetailDto cdDto) throws Exception{
		return codeDetailDaoReamote.deleteCodeDetail(cdDto);
	}
    
    private void initializeCodeDetailDaoHome() throws Exception {
        String FACADE_NAME = "CodeDetailDaoBean";
        Class FACADE_CLASS = beans.CodeDetailDaoHome.class;
        if (codeDetailDaoHome == null) {
            try {
                WhiteDaoLocator locator = WhiteDaoLocator.getInstance();
                codeDetailDaoHome = (CodeDetailDaoHome) WhiteDaoLocator.getEjbHome(FACADE_NAME, FACADE_CLASS);
                if (codeDetailDaoHome == null) {
                    throw new Exception("Did not get home for " + FACADE_NAME);
                }
            } catch (WhiteDaoLocatorException e) {
                throw new Exception(e.getMessage());
            }
        }
    }
}
